using UnityEngine;
using System.Collections;

/// \class  gkAbyssalGiantRockDestructionComponent
/// \brief  Handle the rock destruction when exploded
[AddComponentMenu("GK/AbyssalGiant/Rock/gkAbyssalGiantRockDestructionComponent")]
public class gkAbyssalGiantRockDestructionComponent : MonoBehaviour 
{
	/// \brief  Called when the component is enabled
	void OnEnable() 
	{
		// Listen the shock event of the owner
		GetComponent<gkEventComponent>().AddEventHandler(gkAbyssalGiantExplosionEvent.Explosion, HandleExplosionEvent);
	}
	
	/// \brief  Called when the component is disabled
	void OnDisable() 
	{	
		// Remove the shock event of the owner
		GetComponent<gkEventComponent>().RemoveEventHandler(gkAbyssalGiantExplosionEvent.Explosion, HandleExplosionEvent);
	}
	
	/// Handle the boost event
	void HandleExplosionEvent(Object a_rEvent)
	{
		// Auto destroy
		Destroy(gameObject);
	}
}
